import { Component, OnInit, SimpleChanges } from '@angular/core';
import {Router} from "@angular/router";
// import  { KDMResponseModel} from "../../../../share/models/kdm-response-model"
import {GetOrginizationService} from "../../../../share/services/get-orginization.service"
import {Location} from '@angular/common'

@Component({
  selector: 'app-diagnostic-tool-group-overview',
  templateUrl: './group-overview.component.html',
  styleUrls: ['./group-overview.component.css','../../../../share/css/button.css'],
  providers:[GetOrginizationService]
})
export class GroupOverviewComponent implements OnInit {
  constructor(
    private router: Router,
    private getOrg:GetOrginizationService,
    private location:Location
  ){}
  public id:number=0;
  public totalKks:string='HDZ00W00';
  public regionNum: number=0;
  public startTime: string = '';
  public endTime: string = '';
  ngOnInit() {
    this.staticTime=2;
    let date = new Date();
    let month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1;
    let day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate();
    this.startTime=date.getFullYear() + '-' + '01-01';
    this.endTime = date.getFullYear() + '-' + month + '-' + day; 
    this.getOrg.getOrg()
      .subscribe(
        orgList=>{
          orgList.forEach(item=>{
            if(item.stationSet){
              this.regionNum++
            }
          })
        }
      )
  }

  public staticTime:number
  freshTime(startTime:string){
    let arr = startTime.split(";")
    this.startTime = arr[0];
    this.endTime = arr[1];
  }
  public goBack(flag?:boolean){
    if(flag){
      this.location.back()
    }
    else {
      this.router.navigate(['/pages/home'])
    }
  }

}
